<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('站内邮箱列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>发件人：</label>
                                <input type="text" name="fasongren"/>
                            </li>
                            <li>
                                <label>发送时间：</label>
                                <input type="text" class="time-input" placeholder="请选择" name="fasongshijian"/>
                            </li>
                            <li>
                                <a class="btn btn-success btn-rounded btn-md" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-md" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-md" id="toolbar" role="group">
                <a class="btn btn-danger btn-rounded btn-md multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:xiaoxi:sendBoxremove">
                    <i class="fa fa-remove"></i> 删除
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
            <div class="modal inmodal fade" id="myModal5" tabindex="-1" role="dialog" aria-hidden="true">
                <div class="modal-dialog modal-lg">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
                            </button>
                            <h4 class="modal-title" style="margin-top: 30px"></h4>
                        </div>
                        <div class="modal-body">
                            <p></p>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var removeFlag = [[${@permission.hasPermi('system:xiaoxi:sendBoxremove')}]];
        var zhuangtaiDatas = [[${@dict.getType('sys_xiaoxi_status')}]];
        var prefix = ctx + "system/xiaoxi";
        function bootstrapTableFieldCellStyle() {
            return {
                css: {
                    "max-width": "100px" ,
                    "white-space": "nowrap" ,
                    "text-overflow": "ellipsis" ,
                    "overflow": "hidden" ,
                }
            };
        }
        $(function() {
            //绑定模态框展示的方法
            $('#myModal5').on('show.bs.modal', function (event) {
                var button = $(event.relatedTarget) // 触发事件的按钮
                var biaoti = button.data('biaoti')
                var neirong = button.data('neirong')
                var modal = $(this)  //获得模态框本身
                modal.find('.modal-title').text(biaoti)
                modal.find('.modal-body p').text(neirong)
            })

            var options = {
                url: prefix + "/sendBoxlist",
                removeUrl: prefix + "/sendBoxremove",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                modalName: "站内邮箱",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'xiaoxiid',
                    title: 'xiaoxiid',
                    visible: false
                },
                {
                    field: 'fasongren',
                    title: '发件人'
                },
                {
                    field: 'fasongshijian',
                    width:100,
                    title: '发送时间',
                },
                {
                    field: 'biaoti',
                    title: '邮件标题'
                },
                {
                    field: 'neirong',
                    title: '邮件内容',
                    formatter: function(value, row, index) {
                        if(value.length>200)return value.substr(0, 200) + "...";
                        return value
                    }
                },
                {
                    field: 'jieshouren',
                    title: '接收人',
                    cellStyle: bootstrapTableFieldCellStyle,
                },
                {
                    title: '操作',
                    align: 'center',
                    width:200,
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs " data-toggle="modal" data-target="#myModal5" data-biaoti="'+row.biaoti+'" data-neirong="'+row.neirong+'"><i class="fa fa-edit"></i>查看</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.xiaoxiid + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>